<html>
<head><meta charset="utf-8"><title>Stability of 1-ZSTness · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stability.20of.201-ZSTness.html">Stability of 1-ZSTness</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="215120408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stability%20of%201-ZSTness/near/215120408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stability.20of.201-ZSTness.html#215120408">(Oct 30 2020 at 16:44)</a>:</h4>
<p>The confluence of conversations about <code>Freeze</code>, about <code>NeglectStability</code>, about the trait split for safe-transmute, and about the <code>repr(transparent)</code> relaxation made me think:</p>
<p><strong><code>#[repr(transparent)]</code> means that it's now a breaking change to change a <code>struct Foo(());</code> to a <code>struct Foo(i32);</code>, even in just <code>repr(rust)</code>.</strong></p>
<p>I wonder if the rule should change from "<code>T</code> is a 1-ZST" to "<code>for&lt;'a&gt; &amp;'a T: TransmuteFrom&lt;&amp;'a ()&gt;</code>"...</p>



<a name="215124305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stability%20of%201-ZSTness/near/215124305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stability.20of.201-ZSTness.html#215124305">(Oct 30 2020 at 17:15)</a>:</h4>
<p>If you don't add <code>#[repr(transparent)]</code> to <code>Foo</code> then it shouldn't be a breaking change, right? <code>#[repr(rust)]</code> means that rustc can represent it the same as <code>i32</code> even when it is a ZST.</p>



<a name="215156490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stability%20of%201-ZSTness/near/215156490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stability.20of.201-ZSTness.html#215156490">(Oct 30 2020 at 22:08)</a>:</h4>
<p>The problem is that if I do <code>pub struct Foo(());</code>, <em>someone in another crate</em> can do <code>#[repr(transparent)] struct Bar(i32, Foo);</code>.</p>



<a name="215156568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stability%20of%201-ZSTness/near/215156568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stability.20of.201-ZSTness.html#215156568">(Oct 30 2020 at 22:09)</a>:</h4>
<p>And that's not a promise I affirmatively opted-in to making -- arguably by using a private field I was explicitly trying <em>not</em> to make a promise here.</p>



<a name="215159713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stability%20of%201-ZSTness/near/215159713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stability.20of.201-ZSTness.html#215159713">(Oct 30 2020 at 22:51)</a>:</h4>
<p>Hmm, actually, if I make <code>Foo</code> be <code>#[non_exhaustive]</code> then this seems like it's definitely undesirable.  Filed that part as a bug, <a href="https://github.com/rust-lang/rust/issues/78586">https://github.com/rust-lang/rust/issues/78586</a></p>
<p>(Maybe with Safe Transmute we'd be able to expand that further to require the explicit opt-in even without <code>non_exhaustive</code>, but for now the narrower bug is more obviously a mistake.)</p>



<a name="222228742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Stability%20of%201-ZSTness/near/222228742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Stability.20of.201-ZSTness.html#222228742">(Jan 10 2021 at 16:09)</a>:</h4>
<p>This is a neat issue, so I wrote a blog post cataloguing the sorts of changes that can alter 1-ZSTness: <a href="https://jack.wrenn.fyi/blog/semver-snares-transparent/">https://jack.wrenn.fyi/blog/semver-snares-transparent/</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>